import {
  ChoiceConditionTypes, DateConditionTypes, NumberConditionTypes,
  StringConditionTypes, SwitchConditionTypes
} from './condition'

export default {
  name: 'condition-minix',
  methods: {
    getCompName(){
      if (this.isNumberBetween()) {
        return 'numberRange'
      } else if (this.isNumber()) {
        return 'number'
      } else if (this.isChoiceMulti()) {
        return 'choiceMulti'
      } else if (this.isChoice()) {
        return 'choice'
      } else if (this.isDate()) {
        return 'dateRange'
      } else if (this.isSwitch()) {
        return 'switch'
      }else {
        return 'input'
      }
    },
    isString() {
      return this.formData.el && StringConditionTypes.includes(this.formData.el.type)
    },
    isChoice() {
      return this.formData.el && ChoiceConditionTypes.includes(this.formData.el.type)
    },
    isSwitch() {
      return this.formData.el && SwitchConditionTypes.includes(this.formData.el.type)
    },
    isChoiceMulti() {
      return this.isChoice() && (this.isOneOf() || this.isContains())
    },
    isOneOf() {
      return this.formData.compare && this.formData.compare.value.indexOf('one_of_which') > -1
    },
    isContains() {
      return this.formData.compare && this.formData.compare.value.indexOf('contains') > -1
    },
    isNumber() {
      return this.formData.el && NumberConditionTypes.includes(this.formData.el.type)
    },
    isNumberBetween() {
      return this.isNumber() && this.isBetween()
    },
    isBetween() {
      return this.formData.compare && this.formData.compare.value.indexOf('between') > -1
    },
    isDate() {
      return this.formData.el && DateConditionTypes.includes(this.formData.el.type)
    },
    isRegex() {

    }
  }
}
